package com.actions.bluetoothbox2.util;

import com.actions.bluetoothbox2.app.MyApplication;

import java.util.List;

/**
 * Created by liuyong on 2018/6/15.
 */

public class DButils {

    /**
     * 添加数据
     *
     * @param info
     * @return
     */
    public static boolean insertCart(VoiceInfo info) {
        MyApplication.getDaoInstant().getVoiceInfoDao().insertOrReplace(info);
        return true;
    }

    /**
     * 添加数据
     *
     * @param info
     * @return
     */
    public static boolean insertReport(SchoolReportInfo info) {
        MyApplication.getDaoInstant().getSchoolReportInfoDao().insertOrReplace(info);
        return true;
    }

    /**
     * 查询全部数据
     */
    public static List<VoiceInfo> queryAll() {
        return MyApplication.getDaoInstant().getVoiceInfoDao().loadAll();
    }

    /**
     * 查询全部数据
     */
    public static List<SchoolReportInfo> queryReportAll() {
        return MyApplication.getDaoInstant().getSchoolReportInfoDao().loadAll();
    }

    /**
     * 更新数据
     *
     */
    public static void updateLove(VoiceInfo info) {
        MyApplication.getDaoInstant().getVoiceInfoDao().update(info);
    }

    public static void updateReport(SchoolReportInfo info) {
        MyApplication.getDaoInstant().getSchoolReportInfoDao().update(info);
    }

    /**
     * 删除数据
     *
     * @param id
     */
    public static void deleteLove(long id) {
        MyApplication.getDaoInstant().getVoiceInfoDao().deleteByKey(id);
    }

    /**
     * 删除数据
     *
     * @param id
     */
    public static void deleteReport(long id) {
        MyApplication.getDaoInstant().getSchoolReportInfoDao().deleteByKey(id);
    }

    /**
     * 删除全部
     */
    public static void deleteLove() {
        MyApplication.getDaoInstant().getVoiceInfoDao().deleteAll();
    }


}
